package com.kws.merchant.controller;


import com.kws.common.security.auth.AuthUtil;
import com.kws.merchant.domain.ContractSignature;
import com.kws.merchant.domain.po.ContractSignaturePo;
import com.kws.merchant.service.ContractSignatureService;
import com.kws.system.api.domain.SysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import com.kws.common.core.domain.R;

import javax.annotation.Resource;
import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
 * 合同管理-签名管理(ContractSignature)表控制层
 *
 * @author yxy
 * @since 2024-10-29 15:37:31
 */
@RestController
@Api(tags = "合同管理-签名管理(ContractSignature)")
@RequestMapping("contractSignature")
public class ContractSignatureController {
    /**
     * 服务对象
     */
    @Resource
    private ContractSignatureService contractSignatureService;
 
    @PostMapping("/page")
    @ApiOperation(value = "分页查询列表")
    public R<Page<ContractSignature>> pageList(@RequestBody ContractSignaturePo contractSignaturePo){
        return R.ok(contractSignatureService.pageList(contractSignaturePo));
    }

    /*@GetMapping("/detailById/{id}")
    @ApiOperation(value = "通过主键查询单条数据")
    public R detailById(@PathVariable Long id) {
        return R.ok(contractSignatureService.getById(id));
    }
*/

    @PostMapping("/add")
    @ApiOperation(value = "新增签名")
    public R add(@RequestBody ContractSignature contractSignature) {
        SysUser sysUser = AuthUtil.getLoginUser().getSysUser();
        contractSignature.setUserId(sysUser.getUserId());
        return R.ok(contractSignatureService.save(contractSignature));
    }

    /*@PostMapping("/update")
    @ApiOperation(value = "修改数据")
    public R update(@RequestBody ContractSignature contractSignature) {
        return R.ok(contractSignatureService.updateById(contractSignature));
    }*/


    @PostMapping("/delete")
    @ApiOperation(value = "删除数据")
    public R delete(@RequestBody List<Long> idList) {
        return R.ok(contractSignatureService.removeByIds(idList));
    }
}
